<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>CSS-龙卷风</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 100%;
    }

    .container {
      position: absolute;
      top: 20%;
      width: 100%;
      max-width: 414px;
      height: 80%;
      margin: 0 auto;
      transform-style: preserve-3d;
      perspective: 600px;
      perspective-origin: top center;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      filter: drop-shadow(0 0 3px #f00);
    }

    .line {
      position: relative;
      width: 0;
      height: 0;
    }

    .inner {
      position: absolute;
      left: -50px;
      top: -50px;
      width: 100px;
      height: 100px;
      border-radius: 50%;
      border-left: solid 4px #fff;
      border-top: solid 8px transparent;
      animation: rotate 1s linear infinite;
      filter: drop-shadow(0 0 3px #fff);
    }

    @keyframes rotate {
      0% {
        transform: rotateZ(0deg);
      }

      100% {
        transform: rotateZ(360deg);
      }
    }
  </style>
</head>

<body bgcolor="#000000">
  <div class="container" id="box"></div>

</body>
<script>

  function createStorm() {
    var fragment = document.createDocumentFragment()
    var len = 170
    var step = 1.5
    for (var i = 0; i < len; i++) {
      var top = -i * step
      var div = createDiv('line', top + 'px')
      var left = ~~(Math.cos(i * step * Math.PI * 2 / len) * 10)
      var inner = createDiv('inner')
      inner.style.animationDelay = -~~(Math.random() * 1000) + 'ms'
      inner.style.animationDuration = 300 + ~~(Math.random() * 800) + 'ms'
      inner.style.borderColor = 'rgb(' + 255 + ',' + ~~(Math.random() * 155 + 100) + ',' + 0 + ')'
      inner.style.transformOrigin = (45 + Math.random() * 10) + '% ' + (45 + Math.random() * 10) + '%'
      var scale = -top / len / step * 2
      scale += 0.1 - Math.random() * 0.1
      div.style.transform = 'rotateX(80deg) scale(' + scale + ') translate3d(' + ~~left + 'px,0,0)'
      div.appendChild(inner)
      fragment.appendChild(div)
    }
    document.getElementById('box').appendChild(fragment)
  }

  function createDiv(cName, top) {
    var div = document.createElement('div')
    div.className = cName
    top && (div.style.top = top)
    return div
  }
  window.onload = function () {
    createStorm()
  }
</script>

</html>